//
//  UIImage+Category.m
//  RQJJ
//
//  Created by Red App on 2017/10/26.
//  Copyright © 2017年 Dc.lee. All rights reserved.
//

#import "UIImage+Category.h"
#import <AVKit/AVKit.h>

@implementation UIImage (Category)
+(UIImage *)getThumbnailImage:(NSString *)videoURL
{
    
    AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:[NSURL fileURLWithPath:videoURL] options:nil];
    
    AVAssetImageGenerator *gen = [[AVAssetImageGenerator alloc] initWithAsset:asset];
    
    gen.appliesPreferredTrackTransform = YES;
    
    CMTime time = CMTimeMakeWithSeconds(0.0, 600);
    
    NSError *error = nil;
    
    CMTime actualTime;
    
    CGImageRef image = [gen copyCGImageAtTime:time actualTime:&actualTime error:&error];
    
    UIImage *thumb = [[UIImage alloc] initWithCGImage:image];
    
    CGImageRelease(image);
    
    return thumb;
}
@end
